import Vue from 'vue'
import Router from 'vue-router'
import store from '@/store'
Vue.use(Router)

import Layout from '@/layout'

let whiteList = []

const routes = [{
		path: '/',
		component: Layout,
		redirect: '/index',
		children: [{
				path: 'index',
				name: 'Index',
				component: () => import('@/views/index/index'),
				meta: {
					title: '主页',
					affix: true
				}
			},
			{
				path: 'house',
				name: 'House',
				component: () => import('@/views/house/index'),
				meta: {
					title: '二手房出售',
					affix: true
				}
			},
			{
				path: 'notice',
				name: 'Notice',
				component: () => import('@/views/notice/index'),
				meta: {
					title: '公告栏',
					affix: true
				}
			},
			{
				path: 'myHome',
				name: 'MyHome',
				component: () => import('@/views/myHome/index'),
				children: [{
						path: 'myHouse',
						name: 'MyHouse',
						component: () => import('@/views/myHome/components/myHouse'),
						meta: {
							title: '我的房源',
							affix: true
						}
					},
					{
						path: 'commitHouse',
						name: 'CommitHouse',
						component: () => import('@/views/myHome/components/commitHouse'),
						meta: {
							title: '发布房源',
							affix: true
						}
					},
					{
						path: 'myOrder',
						name: 'MyOrder',
						component: () => import('@/views/myHome/components/myOrder'),
						meta: {
							title: '我的订单',
							affix: true
						}
					},
					{
						path: 'my',
						name: 'My',
						component: () => import('@/views/myHome/components/my'),
						meta: {
							title: '个人中心',
							affix: true
						}
					},
					{
						path: 'changePwd',
						name: 'ChangePwd',
						component: () => import('@/views/myHome/components/changePwd'),
						meta: {
							title: '修改密码',
							affix: true
						}
					},
					//TODO oss测试
					// {
					// 	path: 'imgUpload',
					// 	name: 'ImgUpload',
					// 	component: () => import('@/views/myHome/components/imgUpload'),
					// 	meta: {
					// 		title: 'oss测试',
					// 		affix: true
					// 	}
					// },
					{
						path: 'orderDetail',
						name: 'OrderDetail',
						component: () => import('@/views/myHome/components/orderDetail'),
						meta: {
							title: '订单详情',
							affix: true
						}
					},
					{
						path: 'mySale',
						name: 'MySale',
						component: () => import('@/views/myHome/components/mySale'),
						meta: {
							title: '我的卖出',
							affix: true
						}
					}

				]
			},
			{
				path: 'detail',
				name: 'Detail',
				component: () => import('@/views/detail/index'),
				meta: {
					title: '房源信息',
					affix: true
				}
			},
		]
	},

]


const router = new Router({
	routes
})

// 路由守护
router.beforeEach((to, from, next) => {
	// if (!store.getters.token) {
	// 	console.log("err")
	// 	next("/")
	// } else {
	// 	next()
	// }
	// 	// } else {
	// 	// 	next()
	// 	// }
		next()
})
export default router
